﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ProductCollector;
using System.Web.UI.HtmlControls;

namespace ThemeCupid.FrontEnd
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadDefaultProduct();
            }
        }

        public void LoadDefaultProduct()
        {
            string siteName = "Aeiomed";
            string category = "";
            string value = "";

            ISiteSearcher searcher = SiteSearcherFactory.CreateSearcher(siteName);
            var searchCriteria = new SearchCriteria
            {
                Category = category,
                SearchValue = value,
                CurrentPageIndex = 1,
                AllCategory = true
            };
            var productList = searcher.Search(searchCriteria);
            DataList1.DataSource = productList;
            DataList1.DataBind();
        }

        protected void btnAddToCart_Click(object sender, EventArgs e)
        {
            HtmlButton button = (HtmlButton) sender;
            var productId= button.Attributes["data"];
            Response.Redirect("AddToCart.aspx?productId="+productId);
        }

    }
}